package com.hyz.listener;

import com.alibaba.fastjson.JSON;
import com.hyz.model.SecondmentLog;
import com.hyz.service.SecondmentLogService;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author HGD
 * @date 2022/10/10 19:47
 */
@Component
public class SecondmentLogListener {
    @Autowired
    private SecondmentLogService service;

    @RabbitHandler
    @RabbitListener(queuesToDeclare = @Queue("secondmentLog"))
    public void insertSecondmentLog(String message) {
        SecondmentLog secondmentLog = JSON.parseObject(message, SecondmentLog.class);
        service.save(secondmentLog);
    }
}
